#pragma once

namespace Knight {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
    typedef struct _link{
        int i;
        int j;
        bool visited;
    }link;

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
            drawing = gcnew Bitmap(this->Width,this->Height);
         
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
    private: System::Windows::Forms::GroupBox^  groupBox1;
    protected: 
    private: System::Windows::Forms::CheckBox^  checkBox1;

    private: System::Windows::Forms::Button^  button1;

    private: System::Windows::Forms::Label^  label3;


    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::NumericUpDown^  numericUpDown3;
    private: System::Windows::Forms::NumericUpDown^  numericUpDown2;
    private: System::Windows::Forms::NumericUpDown^  numericUpDown1;




	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;
        void Initialize();
        void DrawNeurons();
        bool CheckHamiltonian();
        bool hamiltonian;

        int  XSIZE,YSIZE;
        int Count;
        Bitmap ^drawing;
        int i, j;
        int **V, **U, **D, **A;
        int CSIZE, DSIZE, NSIZE, flag;

        bool stopped;
        link **links;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
            this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
            this->numericUpDown3 = (gcnew System::Windows::Forms::NumericUpDown());
            this->numericUpDown2 = (gcnew System::Windows::Forms::NumericUpDown());
            this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
            this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->groupBox1->SuspendLayout();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown3))->BeginInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown2))->BeginInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->BeginInit();
            this->SuspendLayout();
            // 
            // groupBox1
            // 
            this->groupBox1->BackColor = System::Drawing::Color::White;
            this->groupBox1->Controls->Add(this->numericUpDown3);
            this->groupBox1->Controls->Add(this->numericUpDown2);
            this->groupBox1->Controls->Add(this->numericUpDown1);
            this->groupBox1->Controls->Add(this->checkBox1);
            this->groupBox1->Controls->Add(this->button1);
            this->groupBox1->Controls->Add(this->label3);
            this->groupBox1->Controls->Add(this->label2);
            this->groupBox1->Controls->Add(this->label1);
            this->groupBox1->Location = System::Drawing::Point(13, 13);
            this->groupBox1->Margin = System::Windows::Forms::Padding(4);
            this->groupBox1->Name = L"groupBox1";
            this->groupBox1->Padding = System::Windows::Forms::Padding(4);
            this->groupBox1->Size = System::Drawing::Size(476, 83);
            this->groupBox1->TabIndex = 2;
            this->groupBox1->TabStop = false;
            this->groupBox1->Text = L"Setting";
            // 
            // numericUpDown3
            // 
            this->numericUpDown3->Location = System::Drawing::Point(230, 25);
            this->numericUpDown3->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});
            this->numericUpDown3->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100, 0, 0, 0});
            this->numericUpDown3->Name = L"numericUpDown3";
            this->numericUpDown3->Size = System::Drawing::Size(59, 20);
            this->numericUpDown3->TabIndex = 10;
            this->numericUpDown3->TextAlign = System::Windows::Forms::HorizontalAlignment::Center;
            this->numericUpDown3->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {100, 0, 0, 0});
            // 
            // numericUpDown2
            // 
            this->numericUpDown2->Location = System::Drawing::Point(63, 50);
            this->numericUpDown2->Name = L"numericUpDown2";
            this->numericUpDown2->Size = System::Drawing::Size(59, 20);
            this->numericUpDown2->TabIndex = 9;
            this->numericUpDown2->TextAlign = System::Windows::Forms::HorizontalAlignment::Center;
            this->numericUpDown2->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {8, 0, 0, 0});
            // 
            // numericUpDown1
            // 
            this->numericUpDown1->Location = System::Drawing::Point(63, 25);
            this->numericUpDown1->Name = L"numericUpDown1";
            this->numericUpDown1->Size = System::Drawing::Size(59, 20);
            this->numericUpDown1->TabIndex = 3;
            this->numericUpDown1->TextAlign = System::Windows::Forms::HorizontalAlignment::Center;
            this->numericUpDown1->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {8, 0, 0, 0});
            // 
            // checkBox1
            // 
            this->checkBox1->AutoSize = true;
            this->checkBox1->Location = System::Drawing::Point(207, 51);
            this->checkBox1->Name = L"checkBox1";
            this->checkBox1->Size = System::Drawing::Size(73, 17);
            this->checkBox1->TabIndex = 8;
            this->checkBox1->Text = L"Display all";
            this->checkBox1->UseVisualStyleBackColor = true;
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(358, 29);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(75, 35);
            this->button1->TabIndex = 6;
            this->button1->Text = L"Start";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(192, 27);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(32, 13);
            this->label3->TabIndex = 4;
            this->label3->Text = L"Trials";
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(19, 52);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(38, 13);
            this->label2->TabIndex = 1;
            this->label2->Text = L"Height";
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(19, 27);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(35, 13);
            this->label1->TabIndex = 0;
            this->label1->Text = L"Width";
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(504, 497);
            this->Controls->Add(this->groupBox1);
            this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
            this->Name = L"Form1";
            this->Text = L"Form1";
            this->groupBox1->ResumeLayout(false);
            this->groupBox1->PerformLayout();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown3))->EndInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown2))->EndInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->EndInit();
            this->ResumeLayout(false);

        }
#pragma endregion

    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) ;
    protected: virtual System::Void OnPaint(System::Windows::Forms::PaintEventArgs^ e) override;
    protected: virtual System::Void OnPaintBackground(System::Windows::Forms::PaintEventArgs^ e) override;
};
}

